﻿<!-- Views/Admin/Options.cshtml -->
@model List<WebApplication1.Models.Option>

@{
    ViewBag.Title = "选项管理";
    Layout = "~/Views/Shared/_Layout.cshtml";
}

<div class="container">
    <h2>选项管理</h2>
    <h4>@ViewBag.QuestionText</h4>
    <hr />

    <p>
        <a href="@Url.Action("CreateOption", "Admin", new { questionId = ViewBag.QuestionId })" class="btn btn-primary">
            <i class="glyphicon glyphicon-plus"></i> 添加选项
        </a>
        <a href="@Url.Action("Questions", "Admin", new { examId = ViewBag.ExamId })" class="btn btn-danger">
            <i class="glyphicon glyphicon-arrow-left"></i> 返回试题列表
        </a>
    </p>

    @if (Model.Count == 0)
    {
        <div class="alert alert-info">
            <p>暂无选项信息。</p>
        </div>
    }
    else
    {
        <div class="table-responsive">
            <table class="table table-striped table-bordered">
                <thead>
                    <tr>
                        <th width="10%">选项标识</th>
                        <th>选项内容</th>
                        <th width="20%">操作</th>
                    </tr>
                </thead>
                <tbody>
                    @foreach (var option in Model.OrderBy(o => o.OptionLabel))
                    {
                        <tr>
                            <td><strong>@option.OptionLabel</strong></td>
                            <td>@option.OptionText</td>
                            <td>
                                <div class="btn-group btn-group-sm" role="group">
                                    <a href="@Url.Action("EditOption", "Admin", new { id = option.OptionId })"
                                       class="btn btn-warning" title="编辑">
                                        <i class="glyphicon glyphicon-edit"></i> 编辑
                                    </a>
                                    <a href="@Url.Action("DeleteOption", "Admin", new { id = option.OptionId })"
                                       class="btn btn-danger" title="删除">
                                        <i class="glyphicon glyphicon-trash"></i> 删除
                                    </a>
                                </div>
                            </td>
                        </tr>
                    }
                </tbody>
            </table>
        </div>
    }
</div>

@section Scripts {
    <script>
        $(document).ready(function() {
            // 删除确认
            $('a[href*="DeleteOption"]').click(function(e) {
                if (!confirm('确定要删除这个选项吗？')) {
                    e.preventDefault();
                }
            });
        });
    </script>
}